/*java jdk 1.7+
# -*- coding: utf-8 -
'''
Created on 2022年6月15日
@author: zxyong 13738196011
'''*/

package com.plugins.usereflect;

import java.io.File;
import java.io.IOException;

import org.json.JSONArray;
import org.json.JSONObject;

import com.zxy.adminlog.UsAdmin_Log;
import com.zxy.business.Ope_DB_Cent;
import com.zxy.common.Com_Fun;
import com.zxy.common.Com_Para;

//导入接口拦截器
public class A01_INPROC_IN implements com.zxy.common.ParamName_InterFace
{
	public StringBuilder	strResult		= new StringBuilder();
	public String			user_main_id			= null;
	public String			session_id		= null;
	public String			param_name		= "";
	public String			param_value1	= null;
	public String			param_value2	= null;
	public String			param_value3	= null;
	public String			param_value4	= null;
	public String			param_value5	= null;
	public String			param_value6	= null;
	public String			param_value7	= null;
	public String			param_value8	= null;
	public String			param_value9	= null;
	public String			param_value10	= null;

	public void init_start()
	{
		String temStrTFileName = "";
		if(!java.util.Objects.equals(this.param_value1,null)
				&& !this.param_value1.equals(""))
			if(com.zxy.common.Com_Para.UpLoad_File.equals(""))
			{
				temStrTFileName = Com_Fun.GetAbsPath() + this.param_value1;
			}else
			{
				temStrTFileName = com.zxy.common.Com_Para.UpLoad_File
						+ Com_Para.zxyPath + this.param_value1;
			}
		else
			temStrTFileName = this.param_value10;
		File fiFile = new File(temStrTFileName);
		if(!fiFile.isFile())
		{
			this.strResult.delete(0,this.strResult.length());
			this.strResult.append(Com_Fun.get_ope_result(param_name,"0","异常:附件文件不存在"));
		}else
		{
			try
			{
				UsAdmin_Log uL = new UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder(""));
				StringBuilder sbo = uL.ReadFile(temStrTFileName);
				JSONObject jsonObject = new JSONObject(sbo.toString());
				Ope_DB_Cent opc = new Ope_DB_Cent();
				if(!java.util.Objects.equals(jsonObject,null)
						&& jsonObject.has("t_proc_name"))
				{
					JSONArray jsary = jsonObject.getJSONArray("t_proc_name");
					for(int i = 0;i < jsary.length();i++)
					{
						JSONObject jso_t_proc_name = jsary.getJSONObject(i);
						String PROC_ID = opc.get_t_proc_name_id(jso_t_proc_name.getString("INF_EN_NAME"));
						if(PROC_ID.equals(""))
						{
							opc.Ins_Data_JSON(jso_t_proc_name,"t_proc_name",PROC_ID);
							PROC_ID = opc.get_t_proc_name_id(jso_t_proc_name.getString("INF_EN_NAME"));
							// 表t_proc_inparam
							if(!java.util.Objects.equals(jsonObject,null)
									&& jsonObject.has("t_proc_inparam"))
							{
								JSONArray jsary_t_proc_inparam = jsonObject.getJSONArray("t_proc_inparam");
								for(int n = 0;n < jsary_t_proc_inparam.length();n++)
								{
									JSONObject jso_t_proc_inparam = jsary_t_proc_inparam.getJSONObject(n);
									if(jso_t_proc_inparam.getString("PROC_ID").equals(jso_t_proc_name.getString("MAIN_ID")))
										opc.Ins_Data_JSON(jso_t_proc_inparam,"t_proc_inparam",PROC_ID);
								}
							}
							// 表t_proc_outparam
							if(!java.util.Objects.equals(jsonObject,null)
									&& jsonObject.has("t_proc_outparam"))
							{
								JSONArray jsary_t_proc_outparam = jsonObject.getJSONArray("t_proc_outparam");
								for(int n = 0;n < jsary_t_proc_outparam.length();n++)
								{
									JSONObject jso_t_proc_outparam = jsary_t_proc_outparam.getJSONObject(n);
									if(jso_t_proc_outparam.getString("PROC_ID").equals(jso_t_proc_name.getString("MAIN_ID")))
										opc.Ins_Data_JSON(jso_t_proc_outparam,"t_proc_outparam",PROC_ID);
								}
							}
							// 表t_proc_return
							if(!java.util.Objects.equals(jsonObject,null)
									&& jsonObject.has("t_proc_return"))
							{
								JSONArray jsary_t_proc_return = jsonObject.getJSONArray("t_proc_return");
								for(int n = 0;n < jsary_t_proc_return.length();n++)
								{
									JSONObject jso_t_proc_return = jsary_t_proc_return.getJSONObject(n);
									if(jso_t_proc_return.getString("PROC_ID").equals(jso_t_proc_name.getString("MAIN_ID")))
										opc.Ins_Data_JSON(jso_t_proc_return,"t_proc_return",PROC_ID);
								}
							}
							// 表t_sub_power
							if(!java.util.Objects.equals(jsonObject,null)
									&& jsonObject.has("t_sub_power"))
							{
								JSONArray jsary_t_sub_power = jsonObject.getJSONArray("t_sub_power");
								for(int n = 0;n < jsary_t_sub_power.length();n++)
								{
									JSONObject jso_t_sub_power = jsary_t_sub_power.getJSONObject(n);
									if(jso_t_sub_power.getString("PROC_ID").equals(jso_t_proc_name.getString("MAIN_ID")))
										opc.Ins_Data_JSON(jso_t_sub_power,"t_sub_power",PROC_ID);
								}
							}
							// 表t_sub_userpower
							if(!java.util.Objects.equals(jsonObject,null)
									&& jsonObject.has("t_sub_userpower"))
							{
								JSONArray jsary_t_sub_userpower = jsonObject.getJSONArray("t_sub_userpower");
								for(int n = 0;n < jsary_t_sub_userpower.length();n++)
								{
									JSONObject jso_t_sub_userpower = jsary_t_sub_userpower.getJSONObject(n);
									if(jso_t_sub_userpower.getString("PROC_ID").equals(jso_t_proc_name.getString("MAIN_ID")))
										opc.Ins_Data_JSON(jso_t_sub_userpower,"t_sub_userpower",PROC_ID);
								}
							}
						}
					}
				}
				this.strResult.delete(0,this.strResult.length());
				this.strResult.append(Com_Fun.get_ope_result(param_name,"1","接口数据导入成功"));
			}
			catch(Exception e)
			{
				Com_Fun.debug_in(e,this.toString());
				this.strResult.delete(0,this.strResult.length());
				this.strResult.append(Com_Fun.get_ope_result(param_name,"0","接口数据导入失败"+ e.getMessage()));
			}
		}
	}

	/**
	 * @return strResult
	 */
	public StringBuilder getStrResult()
	{
		return strResult;
	}

	/**
	 * @param strResult
	 *            要设置的 strResult
	 */
	public void setStrResult(StringBuilder strResult)
	{
		this.strResult = strResult;
	}

	/**
	 * @return user_main_id
	 */
	public String getUser_main_id()
	{
		return user_main_id;
	}

	/**
	 * @param user_main_id
	 *            要设置的 user_main_id
	 */
	public void setUser_main_id(String user_main_id)
	{
		this.user_main_id = user_main_id;
	}

	/**
	 * @return session_id
	 */
	public String getSession_id()
	{
		return session_id;
	}

	/**
	 * @param session_id
	 *            要设置的 session_id
	 */
	public void setSession_id(String session_id)
	{
		this.session_id = session_id;
	}

	/**
	 * @return param_name
	 */
	public String getParam_name()
	{
		return param_name;
	}

	/**
	 * @param param_name
	 *            要设置的 param_name
	 */
	public void setParam_name(String param_name)
	{
		this.param_name = param_name;
	}

	/**
	 * @return param_value1
	 */
	public String getParam_value1()
	{
		return param_value1;
	}

	/**
	 * @param param_value1
	 *            要设置的 param_value1
	 */
	public void setParam_value1(String param_value1)
	{
		this.param_value1 = param_value1;
	}

	/**
	 * @return param_value2
	 */
	public String getParam_value2()
	{
		return param_value2;
	}

	/**
	 * @param param_value2
	 *            要设置的 param_value2
	 */
	public void setParam_value2(String param_value2)
	{
		this.param_value2 = param_value2;
	}

	/**
	 * @return param_value3
	 */
	public String getParam_value3()
	{
		return param_value3;
	}

	/**
	 * @param param_value3
	 *            要设置的 param_value3
	 */
	public void setParam_value3(String param_value3)
	{
		this.param_value3 = param_value3;
	}

	/**
	 * @return param_value4
	 */
	public String getParam_value4()
	{
		return param_value4;
	}

	/**
	 * @param param_value4
	 *            要设置的 param_value4
	 */
	public void setParam_value4(String param_value4)
	{
		this.param_value4 = param_value4;
	}

	/**
	 * @return param_value5
	 */
	public String getParam_value5()
	{
		return param_value5;
	}

	/**
	 * @param param_value5
	 *            要设置的 param_value5
	 */
	public void setParam_value5(String param_value5)
	{
		this.param_value5 = param_value5;
	}

	/**
	 * @return param_value6
	 */
	public String getParam_value6()
	{
		return param_value6;
	}

	/**
	 * @param param_value6
	 *            要设置的 param_value6
	 */
	public void setParam_value6(String param_value6)
	{
		this.param_value6 = param_value6;
	}

	/**
	 * @return param_value7
	 */
	public String getParam_value7()
	{
		return param_value7;
	}

	/**
	 * @param param_value7
	 *            要设置的 param_value7
	 */
	public void setParam_value7(String param_value7)
	{
		this.param_value7 = param_value7;
	}

	/**
	 * @return param_value8
	 */
	public String getParam_value8()
	{
		return param_value8;
	}

	/**
	 * @param param_value8
	 *            要设置的 param_value8
	 */
	public void setParam_value8(String param_value8)
	{
		this.param_value8 = param_value8;
	}

	/**
	 * @return param_value9
	 */
	public String getParam_value9()
	{
		return param_value9;
	}

	/**
	 * @param param_value9
	 *            要设置的 param_value9
	 */
	public void setParam_value9(String param_value9)
	{
		this.param_value9 = param_value9;
	}

	/**
	 * @return param_value10
	 */
	public String getParam_value10()
	{
		return param_value10;
	}

	/**
	 * @param param_value10
	 *            要设置的 param_value10
	 */
	public void setParam_value10(String param_value10)
	{
		this.param_value10 = param_value10;
	}
}
